<?php 
use services\models\MemberInfo; 
use services\models\Cart;
use services\models\ClockIn;

$member_no = intval(Yii::$app->session->get(Yii::$app->params['member_no']));
$is_Daka = ClockIn::is_DaKa($member_no);

?>

<div class="sidebar" id="sidebar">
    <div class="sidebar-center">
        <div class="sidebar-item sidebar-user">
            <span class="icon icon-user">
                <?php if($member_no > 0){?>
                <a href="<?=Yii::$app->params['domains']['liketry_url']?>member/index.php">
                    <img <?= MemberInfo::getAvatarByMemberId($member_no) ?> />
                </a>
                <?php } ?>
            </span>
        </div>
        <div class="sidebar-item sidebar-cart">
            <span class="icon icon-cart"></span><i>购物车</i>
            <span class="icon icon-circle"><?= Cart::getUserCartNum(intval(Yii::$app->session->get(Yii::$app->params['uid']))); ?></span>
            <div class="sidebar-pop"><span class="icon icon-pop">全场满<i>9.9</i>包邮</span></div>
        </div>
        <div class="sidebar-item sidebar-sign"><span class="icon <?php echo $is_Daka ? 'icon-signed':'icon-sign';?>"></span><div class="sidebar-pop"><?php echo $is_Daka ? '已签到':'签到';?><span class="icon icon-square"></span></div></div>
        <div class="sidebar-item sidebar-msg">
            <span class="icon icon-msg"></span>
            <div class="sidebar-pop">公告<span class="icon icon-square"></span></div>
        </div>
        <div class="sidebar-item sidebar-qq"><span class="icon icon-qq"></span><div class="sidebar-pop">在线客服<span class="icon icon-square"></span></div></div>
        <div class="sidebar-item sidebar-service"><span class="icon icon-service"></span><div class="sidebar-pop">400-6767-066<span class="icon icon-square"></span></div></div>
    </div>
    <div class="sidebar-btm">
    	<div class="sidebar-item sidebar-code"><span class="icon icon-code"></span><div class="sidebar-pop"><img src="<?= Yii::getAlias('@static')?>/pc/liketry/images/wxcode.png"><span class="icon icon-square"></span></div></div>
        <div class="sidebar-item sidebar-top" id="goTop"><span class="icon icon-arrow-up4"></span><i>TOP</i><div class="sidebar-pop">返回顶部<span class="icon icon-square"></span></div></div>
    </div>
    <input type="hidden" id="is_daka" value="<?php echo $is_Daka ? 1:0; ?>" />
</div>
<?php $this->beginBlock('sidebarJS');?>
  <script>
      var session_uid = '<?php echo intval(Yii::$app->session->get(Yii::$app->params['member_no']))?>';
    $(function(){
		$("#goodsLogoAdFlash").size()>0&&switchColor($("#goodsLogoAdFlash"), ["#fff", "#fff000"]);
		//侧边栏显示动画
		$("#sidebar .sidebar-item").on({"mouseenter": function(){
			$(this).children(".sidebar-pop").show(0).animate({"right": "100%", "opacity": "1"}, 300);
		}, "mouseleave": function(){
			$(this).children(".sidebar-pop").animate({"right": "200%", "opacity": "0"}, 300).hide(0);
		}});
		//返回顶部
		$("#goTop").on("click", function(){
			$("html,body").animate({scrollTop: 0}, 200);
		});
                $('.sidebar-user').click(function(){
                    <?php if($member_no <= 0){?>
                            window.location.href = '<?=Yii::$app->params['domains']['liketry_url']?>auth/login.php';
                    <?php } ?>
                });
		$('.sidebar-cart').click(function(){
                    <?php if($member_no <= 0){?>
                            window.location.href = '<?=Yii::$app->params['domains']['liketry_url']?>auth/login.php';
                    <?php }else{ ?>
                            window.location.href = '<?=Yii::$app->urlManager->createUrl('cart')?>';
                    <?php }?>
		  
		});
		$('.sidebar-msg').click(function(){
		  window.location.href = '<?=Yii::$app->params['domains']['liketry_url']?>info/notice_list.php';
		});
		$('.sidebar-service').click(function(){
		  window.location.href = '<?=Yii::$app->params['domains']['liketry_url']?>member/user_service.php';
		});
		$('.sidebar-qq').click(function(){
		  window.open('http://wpa.qq.com/msgrd?v=3&uin=1730004650&site=qq&menu=yes');
		});
		$('.sidebar-sign').click(function(){
			_hmt.push(['_trackEvent', '打卡PC', 'click', '打卡PC']);
		  if(session_uid == '' || session_uid == '0')
		  {
			  $.go('<?=Yii::$app->params['domains']['liketry_url']?>auth/login.php');
		  }else
		  {
			  var is_daka = $('#is_daka').val();
			  if(is_daka == 1)
                          {
                              window.location.href= '<?=Yii::$app->params['domains']['liketry_url']?>member/user_daka.php';
                              return false;
                          }else
			  {
				  var _this = $(this);
				  $.get("<?=Yii::$app->urlManager->createUrl('index/daka')?>",{rnd:Math.random()},  function(json) {
					if(json.flag == 1)
					{
						$('#is_daka').val(1);
						_this.children(".icon").attr('class','icon icon-signed');
						_this.children(".sidebar-pop").html('已签到<span class="icon icon-square"></span>');
						return false;
					}else
					{
						$.alert(json.msg);
						$('#is_daka').val(0);
						return false;
					}
				 },"json");
			  }
		  }
		});
    });
      
  </script>
<?php $this->endBlock();?>
